// $codepro.audit.disable largeNumberOfParameters, numericLiterals
/**
 * Class: TREATMENT RECORD
 * Description: 
 * 
 */

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;


/**
 * 
 * @author Christian
 * 
 * @version $Revision: 1.0 $
 */

public class TreatmentRecord {

	/**
	 * Field patientUsername.
	 */
	protected String patientUsername;

	/**
	 * Field treatingDoctor.
	 */
	protected String treatingDoctor;

	/**
	 * Field creationDate
	 */
	protected String creationDate;

	/**
	 * Field creationTime.
	 */
	protected final String creationTime;	//Make creationTime uneditable

	/**
	 * Field attendingNurse.
	 */
	protected String attendingNurse;

	/**
	 * Field height.
	 */
	protected String height;	//In inches

	/**
	 * Field weight.
	 */
	protected String weight;	//In lbs

	/**
	 * Field complaint.
	 */
	protected String complaint;

	/**
	 * Field bloodPressure.
	 */
	protected String bloodPressure;	// Formatting: xxx/yyy

	/**
	 * Field pulse.
	 */
	protected String pulse;

	/**
	 * Field temperature.
	 */
	protected String temperature;

	/**
	 * Field diagnosis.
	 */
	protected String diagnosis;

	/**
	 * Field hasDoctorsOrders.
	 */
	private boolean hasDoctorsOrders;

	//Everything past here is considered part of Doctor's Orders
	/**
	 * Field prescription.
	 */
	protected String prescription;	//Comma Delineated		

	/**
	 * Field labWork.
	 */
	protected int labWork;		//Comma Delineated

	/**
	 * Field followUpInstructions.
	 */
	protected String followUpInstructions;

	/**
	 * 
	 * @param billablesReceived
	 */
	public void setBillablesReceived(boolean[] billablesReceived) {
		this.billablesReceived = billablesReceived;
	}

	/**
	 * Field otherInstructions.
	 */
	protected String otherInstructions;
	
	/**
	 * Array of which billables are being used
	 */
	protected boolean[] billablesReceived;

	/**
	 * Constructor for TreatmentRecord.
	 * @param patientUsername String
	 */
	public TreatmentRecord(String patientUsername){	//Treatment Record without parameters
		//Constructor without any input other than who it is for.
		this.patientUsername= patientUsername;
		creationTime = getCurrentTime();
		creationDate = getCurrentDate();
		hasDoctorsOrders = false;

	}

	/**
	 * Constructor for TreatmentRecord.
	 * @param patientUsername String
	 * @param treatingDoctor String
	 * @param attendingNurse String
	 * @param height String
	 * @param weight String
	 * @param complaint String
	 * @param bloodPressure String
	 * @param pulse String
	 * @param temperature String
	 * @param diagnosis String
	 */
	public TreatmentRecord(String patientUsername,
				String treatingDoctor,
				String attendingNurse,
				String height,
				String weight,
				String complaint,
				String bloodPressure,
				String pulse,
				String temperature,
				String diagnosis){
		//Constructor from a Nurse that contains all data BUT doctors orders.
		this.patientUsername = patientUsername;
		creationDate = getCurrentDate();
		creationTime = getCurrentTime();
		this.treatingDoctor = treatingDoctor;
		this.attendingNurse = attendingNurse;
		this.height = height;
		this.weight = weight;
		this.complaint = complaint;
		this.bloodPressure = bloodPressure;
		this.pulse = pulse;
		this.temperature = temperature;
		this.diagnosis = diagnosis;
		hasDoctorsOrders = false;
			
	}

	/**
	 * 
	 * @param information
	 */
	public TreatmentRecord(String[] information){
		this.patientUsername = information[0];
		this.treatingDoctor = information[1];
		creationDate = information[2];
		creationTime = information[3];
		attendingNurse = information[4];
		height = information[5];
		weight = information[6];
		complaint = information[7];
		bloodPressure = information[8];
		pulse = information[9];
		temperature = information[10];
		diagnosis = information[11];
		prescription = information[12];
		labWork = Integer.parseInt(information[13]);
		followUpInstructions = information[14];
		otherInstructions = information[15];
	}

	/**
	 * Method addDoctorsOrders.
	 * @param prescription String
	 * @param labWork String
	 * @param followUpInstructions String
	 * @param otherInstructions String
	 */
	public void addDoctorsOrders(String prescription,
					int labWork,
					String followUpInstructions,
					String otherInstructions){
	
		this.prescription = prescription;
		this.labWork = labWork;
		this.followUpInstructions = followUpInstructions;
		this.otherInstructions = otherInstructions;
		hasDoctorsOrders = true;
	}
	
	/**
	 * 
	 * @param patientUsername
	 * @param treatingDoctor
	 * @param attendingNurse
	 * @param height
	 * @param weight
	 * @param complaint
	 * @param bloodPressure
	 * @param pulse
	 * @param temperature
	 * @param diagnosis
	 */
	public void updateTreatmentRecord(String patientUsername,
				String treatingDoctor,
				String attendingNurse,
				String height,
				String weight,
				String complaint,
				String bloodPressure,
				String pulse,
				String temperature,
				String diagnosis){
		this.patientUsername = patientUsername;
		this.treatingDoctor = treatingDoctor;
		this.attendingNurse = attendingNurse;
		this.height = height;
		this.weight = weight;
		this.complaint = complaint;
		this.bloodPressure = bloodPressure;
		this.pulse = pulse;
		this.temperature = temperature;
		this.diagnosis = diagnosis;
		hasDoctorsOrders = false;
		
	}
	
	/**
	 * Method CalculateBillables
	 * @return The value of the all billables
	 * 
	 * This method calculates the value of all billable items 
	 * used in this treatment record (ie Flu Shots, MRI's)
	 */
	private String getCurrentTime(){
	        final DateFormat dateFormat = new SimpleDateFormat("HH:mm");
	        final Date date = new Date();
	        return dateFormat.format(date);
	}

	/**
	 * 
	 * @return creationDate
	 */
	public String getCreationDate() {
		return creationDate;
	}

	/**
	 * 
	 * @return currentDate
	 */
	private String getCurrentDate(){
	        final DateFormat dateFormat = new SimpleDateFormat("MMM dd yyyy ");
	        final Date date = new Date();
	        return dateFormat.format(date);
	    
	}
	
	/**
	 * 
	 * @return netTotal
	 */
	public int calculateBillables(){
		int netTotal = 0;
		final int[] billables= new int[GlobalVars.NUM_OF_BILLABLE_ITEMS];
		int counter = 0;
		int tempVal = labWork;
		while (tempVal > 0){	//Convert the decimal value to a binary array
			billables[counter] = tempVal % 2;
			tempVal = tempVal >> 1;
			counter++;
		}
		for (int i=0; i < GlobalVars.NUM_OF_BILLABLE_ITEMS; i++){
			if (billables[i] == 1){		//Add up the values 
				netTotal += GlobalVars.BillableItems[i].getCost();
			}
		}
		return netTotal;
	}
	
	/**
	 * @param labWorkNumber
	 * @return An array of ints indicating which indecies need
	 * to be checked 
	 */
	public static int[] getBillablesReceived(int labWorkNumber){
		final int[] billables= new int[GlobalVars.NUM_OF_BILLABLE_ITEMS];
		int counter = 0;
		int tempVal = labWorkNumber;
		while (tempVal > 0){	//Convert the decimal value to a binary array
			billables[counter] = tempVal % 2;
			tempVal = tempVal >> 1;
			counter++;
		}
		return billables;
//		for (int i=0; i<GlobalVars.NUM_OF_BILLABLE_ITEMS; i++){		//If the value is included, make it true
//			if (billables[i] == 1){
//				billablesReceived[i] = true;
//			}	
//			else{
//				billablesReceived[i] = false;
//				
//			}
//		}
//		return billablesReceived;
		
	}
	
	/**
	
	 * @return the patientUsername */
	public String getPatientUsername() {
		return patientUsername;
	}

	/**
	 * @param patientUsername the patientUsername to set
	 */
	public void setPatientUsername(String patientUsername) {
		this.patientUsername = patientUsername;
	}

	/**
	
	 * @return the treatingDoctor */
	public String getTreatingDoctor() {
		return treatingDoctor;
	}

	/**
	 * @param treatingDoctor the treatingDoctor to set
	 */
	public void setTreatingDoctor(String treatingDoctor) {
		this.treatingDoctor = treatingDoctor;
	}

	/**
	
	 * @return the attendingNurse */
	public String getAttendingNurse() {
		return attendingNurse;
	}

	/**
	 * @param attendingNurse the attendingNurse to set
	 */
	public void setAttendingNurse(String attendingNurse) {
		this.attendingNurse = attendingNurse;
	}

	/**
	
	 * @return the height */
	public String getHeight() {
		return height;
	}

	/**
	 * @param height the height to set
	 */
	public void setHeight(String height) {
		this.height = height;
	}

	/**
	
	 * @return the weight */
	public String getWeight() {
		return weight;
	}

	/**
	 * @param weight the weight to set
	 */
	public void setWeight(String weight) {
		this.weight = weight;
	}

	/**
	
	 * @return the complaint */
	public String getComplaint() {
		return complaint;
	}

	/**
	 * @param complaint the complaint to set
	 */
	public void setComplaint(String complaint) {
		this.complaint = complaint;
	}

	/**
	
	 * @return the bloodPressure */
	public String getBloodPressure() {
		return bloodPressure;
	}

	/**
	 * @param bloodPressure the bloodPressure to set
	 */
	public void setBloodPressure(String bloodPressure) {
		this.bloodPressure = bloodPressure;
	}

	/**
	
	 * @return the pulse */
	public String getPulse() {
		return pulse;
	}

	/**
	 * @param pulse the pulse to set
	 */
	public void setPulse(String pulse) {
		this.pulse = pulse;
	}

	/**
	
	 * @return the temperature */
	public String getTemperature() {
		return temperature;
	}

	/**
	 * @param temperature the temperature to set
	 */
	public void setTemperature(String temperature) {
		this.temperature = temperature;
	}

	/**
	
	 * @return the diagnosis */
	public String getDiagnosis() {
		return diagnosis;
	}

	/**
	 * @param diagnosis the diagnosis to set
	 */
	public void setDiagnosis(String diagnosis) {
		this.diagnosis = diagnosis;
	}

	/**
	
	 * @return the hasDoctorsOrders */
	public boolean isHasDoctorsOrders() {
		return hasDoctorsOrders;
	}

	/**
	 * @param hasDoctorsOrders the hasDoctorsOrders to set
	 */
	public void setHasDoctorsOrders(boolean hasDoctorsOrders) {
		this.hasDoctorsOrders = hasDoctorsOrders;
	}

	/**
	 * @return the prescription */
	public String getPrescription() {
		return prescription;
	}

	/**
	 * @param prescription the prescription to set
	 */
	public void setPrescription(String prescription) {
		this.prescription = prescription;
	}

	/**
	
	 * @return the labWork */
	public int getLabWork() {
		return labWork;
	}

	/**
	 * @param labWork the labWork to set
	 */
	public void setLabWork(int labWork) {
		this.labWork = labWork;
	}

	/**
	
	 * @return the followUpInstructions */
	public String getFollowUpInstructions() {
		return followUpInstructions;
	}

	/**
	 * @param followUpInstructions the followUpInstructions to set
	 */
	public void setFollowUpInstructions(String followUpInstructions) {
		this.followUpInstructions = followUpInstructions;
	}

	/**
	
	 * @return the otherInstructions */
	public String getOtherInstructions() {
		return otherInstructions;
	}

	/**
	 * @param otherInstructions the otherInstructions to set
	 */
	public void setOtherInstructions(String otherInstructions) {
		this.otherInstructions = otherInstructions;
	}

	/**
	
	 * @return the creationTime */
	public String getCreationTime() {
		return creationTime.toString();
	}
	
	
}
